/** 分类*/

import { JsonController, Authorized, Body, HeaderParam, Get, Post, UseBefore, QueryParam} from 'routing-controllers';
import { RequestLog } from '@/middleware/requestLog'
import { Inject, Service } from 'typedi';
import { JsonResult, msgList, res } from '@/utils/jsonResult';
import {CommentParams } from "@/model/request/Comment";
import config from '@/config'
import { Token } from '@/m_req/Token'
import { Essayreq } from '@/model/request/Essayreq';
import { classifyServiceImpl } from '@/service/impl/admin/ClassifyServiceImpl';

@Service()
@JsonController(config.setPrefix("admin/classify"))
export class classifyController{

  @Inject()
  classifyServiceImpl!: classifyServiceImpl;

  @Inject()
  json!: JsonResult<any>;  // Promise<res<string>> 
  
  //分类添加
  @Post('/add')
  @UseBefore(RequestLog)

  async add(@Body() params:{categories_title:string}):Promise<any>{
     
    return await this.classifyServiceImpl.classifyadd(params);
  }

  //分类删除
  @Post('/delete')
  @UseBefore(RequestLog)

  async delete(@Body()params:{categories_id:number,categories_title:string}):Promise<any>{
    return await this.classifyServiceImpl.classifydelete(params);
  }


  //分类修改
  @Post('/updata')
  @UseBefore(RequestLog)

  async updata(@Body()params:{categories_id:number,categories_title:string}):Promise<any>{
    return await this.classifyServiceImpl.classifyupdata(params);
  }

    //分类查询
    @Post('/select')
    @UseBefore(RequestLog)
    async select( @Body() params:{page:number}):Promise<any>{
      console.log("params.page",params)
      return await this.classifyServiceImpl.classifyselect(params);
    }

    //标签查询
    @Post('/queries')
    @UseBefore(RequestLog)
    async queries(@Body() params:{text:string}):Promise<any>{
       console.log("paderr",params.text)
      return await this.classifyServiceImpl.classifyqueries(params);
    }

}